using System;
using System.Collections.Generic;
using System.Text;
using Kis.Xroad.Eu;

namespace Kis.Xroad.Eu
{

    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name = "DerivedSequence", Namespace = "http://kis.x-road.eu/", Target = typeof(DerivedSequence))]
    public class DerivedSequenceSerializer : SequenceSerializer
    {


        static DerivedSequenceSerializer()
        {
           // nt.Add("DerSequenceElement");
        }
        public new DerivedSequence clazz
        {
            get
            {
                return (DerivedSequence)base.clazz;
            }

        }

        public DerivedSequenceSerializer(DerivedSequence clazz)
            : base(clazz)
        {
          
        }

        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer)
        {
            base.WriteXml(Writer);
            string element = string.Empty;
            //try {
            element = "DerSequenceElement";
            Writer.WriteStartElement("DerSequenceElement");
            if (clazz.SequenceElement != null)
            {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(clazz.DerSequenceElement);
            }
            else
            {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : DerSequenceElement");
            }
            Writer.WriteEndElement();
            //}
            //catch (System.Exception ) {
            //    throw new global::Xtee.Core.Exceptions.PropertyWriteException(element, this.GetType(), ex);
            //}
        }

        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader)
        {
            base.ReadXml(Reader);
            string element = string.Empty;
            //try {
            element = ">>>DerSequenceElement";
            if (Reader.LocalName == "DerSequenceElement")
            {
                if (Reader.IsElementNil())
                {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>DerSequenceElement");
                }
                clazz.DerSequenceElement = Reader.ReadElementString("DerSequenceElement");
            }
            else
            {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>DerSequenceElement", Reader.LocalName);
            }
            //}
            //catch (System.Exception ) {
            //    throw new global::Xtee.Core.Exceptions.PropertyAssignementException(element, this.GetType(), ex);
            //}
        }
    }
}
